<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      width: 200px;
      height: 200px;
      background-color: #aef;
    }

    .box2{
      width: 200px;
      height: 200px;
      background-color: #aef;
    }
  </style>
</head>
<body>
  <!-- 方式三 -->
  <div class="box" onclick="alert(123)"></div>
  <div class="box2"></div>
  <h2>原生 input</h2>
  <input type="text" >
  <script>
    'use strict';
    //获取元素
    let box = document.querySelector('.box');
    let box2 = document.querySelector('.box2');
    let input = document.querySelector('input');
    //方式一
    box.onclick = function(e){
      // alert(123);
      console.log(e);
    };
    //方式二
    // box.addEventListener('click', function(){
    //   alert(123);
    // });

    let fn = function (){
      console.log(this);
    }

    box2.onclick = fn.bind(undefined);

    //为 input 绑定 change 事件
    input.onchange = function(){
      console.log('change');
    }

    let arr = [1,2,3];

  </script>
</body>
</html>
